package net.csdn.business.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import net.csdn.business.common.constant.AdminRoleConstants;

/**
 * @author zhangyl
 * @date 2022/6/15 16:31
 */
@Getter
@AllArgsConstructor
public enum AdminRoleEnum {

    /**
     * 角色枚举
     */
    ADMIN(AdminRoleConstants.ROLE_ADMIN, "管理者",50),
    OPERATOR(AdminRoleConstants.ROLE_OPERATOR, "运营",10),
    AUDITOR(AdminRoleConstants.ROLE_AUDITOR, "审核员",10),
    ;
    final String code;
    final String desc;
    /**
     * 对应的项目权限的code
     */
    final int level;


    public static AdminRoleEnum ofCode(String code) {
        for (AdminRoleEnum role : AdminRoleEnum.values()) {
            if (role.code.equals(code)) {
                return role;
            }
        }
        throw new IllegalArgumentException("RoleEnum param error");
    }
}